package com.awaken;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

/**
 * Created by IntelliJ IDEA.
 * User: ndemeshchenko
 * Date: Apr 12, 2010
 * Time: 5:21:00 PM
 */
public class TitleValidator implements Validator {
    public void validate(FacesContext facesContext, UIComponent uiComponent, Object o) throws ValidatorException {
        System.out.println("***************** IN THE VALIDATOR");
        String title = o.toString();
        if (title.equals("")) {
            FacesMessage message = new FacesMessage();
            message.setSummary("Title is required");
            throw new ValidatorException(message);
        }
    }
}
